package fab.forms.error 
{
	import fab.forms.fields.Element;
	/**
	 * ...
	 * @author fab
	 */
	public class FormError
	{
		static public const YEARLENGTH:String = "yearlength";
		static public const RB_UNCHECKED:String = "rbUnchecked";
		static public const PHONENUMBER:String = "phonenumber";
		static public const EMAIL:String = "email";
		static public const NONEMPTY:String = "nonempty";
		static public const CHECKED:String = "checked";
		static public var errors:Vector.<FormError> = new Vector.<FormError>();
		public var element:Element;
		public var type:String;
		public var id:String;
		public var message:String;
		
		public function FormError( _id:String,  _type:String, _message:String, _element:Element ) 
		{
			element = _element;
			id = _id;
			type = _type;
			message = _message;
			errors.push( this );
		}
		public function toString() : String
		{
			return "FormError : " + element + "\t" + id + "\t" + message ; 
		}
		static public function getById(id:String) : FormError
		{
			for each ( var err:FormError in errors ) if ( err.id == id ) return err;
			return null;
		}
	}

}